<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
	<link href="style.css" rel="stylesheet" type="text/css"/>
	<link href="style.css" rel="stylesheet" media="only screen and (max-device-width:640px)"/>
	<link href="style.css" rel="stylesheet" type="text/css" media="handheld"/>
	<link rel="icon" href="/favicon.ico" type="image/x-icon">
	<link rel='shortcut icon' type='image/x-icon' href='/favicon.ico' />
	<meta name="author" content="Christopher Blake Reyes" />
	<meta name="description" content="A place where you can find all thing university.">
	<title>tehpost.com // A place where you can find all things university.</title>
</head>

<body>

<div id="wrapper">
	
	<div id="top-bar">
		<div id="title">
			<a href="/"><p class="tehpost-title">tehpost</p></a>
		</div>
	</div>
	
	<div id="content-container">
		
		<div id="head">
			<div id="social">
				<img src="images/social1.png" />
				<img src="images/social2.png" />
				<img src="images/social3.png" />
			</div>
			
			<div id="search">
				
				<form name="fbsearch" method="GET" action="search.php">
				  	<div>
					<span class="search-label">Find Your Campus</span>	
				  	<input type="text" class="search-input" name="search" size="90">
				  	<input type="submit" class="search-button" name="submit" value="Search">
				  	</div>
				</form> 
				
			</div>
			
		</div>
		
		<div id="main">
			
			<div id="search-results">
				<?php

				$button = $_GET ['submit'];
				$search = $_GET ['search']; 
				$count  = 0;
				if(!$button)
				echo "<p>You didn't submit a keyword</p>";
				else
				{
				if(strlen($search)<=1)
				echo "<p>Please enter at least 2 characters!</p>";
				else{
				echo "<p>You searched for <b>$search</b></p>";
				mysql_connect("fdb3.awardspace.com","891782_chris","design3");
				mysql_select_db("891782_chris");

				$search_exploded = explode (" ", $search);

				foreach($search_exploded as $search_each)
				{
				$count++;
				if($count==1)
				$construct .="keywords LIKE '%$search_each%'";
				else
				$construct .="OR keywords LIKE '%$search_each%'";
				}

				$construct ="SELECT * FROM searchengine WHERE $construct";
				$run = mysql_query($construct);
				$foundnum = mysql_num_rows($run);

				if ($foundnum==0)
				echo "<div class='search-info'><p><span>Sorry, there were no results that matched <em>$search</em>.</span>
				Please check your spelling, and if results still are not found then your school might not yet be added to tehpost</p></div>";
				else
				{
				echo "<div class='search-info'><p>Your search returned $foundnum results!</p></div>";
				
				while($search_results = mysql_fetch_assoc($run))
				{
				$title = $search_results ['title'];
				$desc = $search_results ['description'];
				$url = $search_results ['url'];

				echo "
				<div id='results'>
				<a class='search-school-title' href='$url'><span>$title</span></a>
				<p class='search-school-description'>$desc</p>
				</div>
				";

				}
				}

				}
				}

				?>
			</div>
			
		</div>
		
		<div id="footer">
			
		</div>
	
</div>
</body>
</html>
